

package net.prot;

import java.io.*;
import java.util.*;


public class AminoAcidSequence implements Sequence {

    protected static final Hashtable<Character, String> abrevs;

    protected char[] seq;

    static {
	abrevs = new Hashtable<Character, String>();
	abrevs.put(new Character('A'), "Ala");
	abrevs.put(new Character('C'), "Cys");
	abrevs.put(new Character('D'), "Asp");
	abrevs.put(new Character('E'), "Glu");
	abrevs.put(new Character('F'), "Phe");
	abrevs.put(new Character('G'), "Gly");
	abrevs.put(new Character('H'), "His");
	abrevs.put(new Character('I'), "Ile");
	abrevs.put(new Character('K'), "Lys");
	abrevs.put(new Character('L'), "Leu");
	abrevs.put(new Character('M'), "Met");
	abrevs.put(new Character('N'), "Asn");
	abrevs.put(new Character('P'), "Pro");
	abrevs.put(new Character('Q'), "Gln");
	abrevs.put(new Character('R'), "Arg");
	abrevs.put(new Character('S'), "Ser");
	abrevs.put(new Character('T'), "Thr");
	abrevs.put(new Character('V'), "Val");
	abrevs.put(new Character('W'), "Try");
	abrevs.put(new Character('Y'), "Tyr");
	abrevs.put(new Character(' '), "NUL");
	abrevs.put(new Character('-'), "NUL");
	abrevs.put(new Character('_'), "NUL");
        // If an amino acid abrev is not found in here then it is assumed to
	// be not one of the usual human twenty.
    }

    public AminoAcidSequence(){
	seq = new char[0];
    }

    public AminoAcidSequence(char[] seq){
	this.seq = seq;
    }

    public static String lookUpAbrev(char aminoAcid){
	String abrev = abrevs.get(new Character(aminoAcid));
	if (abrev != null){
	    return abrev;
	} else {
	    return "UKN";
	}
    }

    public void setSequenceChars(char[] seq){
	this.seq = seq;
    }

    public char[] getSequenceChars(){
	return seq;
    }

    public void print(){
	print(System.out);
    }

    public void print(PrintStream out){
	out.println(seq);
    }

    public void printAbrev(){
	printAbrev(System.out);
    }

    public void printAbrev(PrintStream out){
	if (seq.length < 1) return;
	out.print(lookUpAbrev(seq[0]));
	for (int i = 1; i < seq.length; i++)
	    out.print("-" + lookUpAbrev(seq[i]));
	out.println();
    }

    public void shiftRight(int index, int spaces){
        char[] newArray = new char[seq.length + spaces];
        for (int i = 0; i < index+1; i++){
            newArray[i] = seq[i];
        }
        for (int i = index+1; i < spaces; i++){
            newArray[i] = ' ';
        }
        for (int i = index+spaces+1; i < newArray.length; i++){
            newArray[i] = seq[i-spaces];
        }
    }

    public void shiftLeft(int index, int spaces){
	
    }

    public void insertAcid(int index, char acid){

    }

    public void deleteAcid(int index){

    }

    public void replaceAcid(int index, char acid){

    }


}
